package com.nuoniu.sibanyun.service.crm.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.crm.CommissionRecord;
import com.nuoniu.sibanyun.mapper.crm.ApprovalMapper;
import com.nuoniu.sibanyun.mapper.crm.ApprovalProcessMapper;
import com.nuoniu.sibanyun.mapper.crm.CommissionRecordMapper;
import com.nuoniu.sibanyun.service.crm.ICommissionRecordService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 佣金记录 服务实现类
 * </p>
 *
 * @author baiqiang
 * @since 2020-07-28
 */
@Service
public class CommissionRecordServiceImpl extends ServiceImpl<CommissionRecordMapper, CommissionRecord> implements ICommissionRecordService {

    @Autowired
    private ApprovalMapper approvalMapper;
    @Autowired
    private ApprovalProcessMapper approvalProcessMapper;
    @Autowired
    private CommissionRecordMapper commissionRecordMapper;

    @Override
    public Page<CommissionRecord> getCommissionRecord(Page pages, CommissionRecord record) {
        UserInfo userInfo = UserThreadLocal.get();
        CommissionRecord commissionRecord = new CommissionRecord();
        QueryWrapper<CommissionRecord> queryWrapper = new QueryWrapper<>(commissionRecord);
        queryWrapper.orderByDesc("create_date");
        queryWrapper.eq("user_id", userInfo.getUserId());
        return page(pages, queryWrapper);
    }
}
